<?php
date_default_timezone_set("Asia/Ho_Chi_Minh");


$proto = 'http';
$memport = 11211;

define('APPLICATION_ENV','production'); 
defined('MEMCACHE_PORT') || define('MEMCACHE_PORT', $memport);

defined('APPLICATION_PATH') 
    || define('APPLICATION_PATH', 
              realpath(dirname(__FILE__) . "/../application")); 

$server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
$port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : '80';
defined('NAME_SPACE')  || define('NAME_SPACE',  "{$server}_{$port}"); 

defined('BASE_URL')  || define('BASE_URL',  "{$proto}://{$server}/"); 

defined('SESSION_NAMESPACE') || define('SESSION_NAMESPACE','Zend_Auth_KPI');

define('PLATFORM','');
define('ROOT_PATH',realpath(dirname(dirname(__FILE__))));   

define('CONFIG_PATH', APPLICATION_PATH . '/configs' );
$envFolder = '';
//Duong dan den thu muc /public
define('WEB_PATH',realpath(dirname(dirname(__FILE__)))."{$envFolder}");
if($envFolder==''){
    define('PUBLIC_PATH', WEB_PATH . '/public');
}else{
    define('PUBLIC_PATH', realpath(dirname(dirname(__FILE__))) . '/public');
}

define('LIBRARY_PATH',dirname(dirname(__FILE__)) . $envFolder . '/library');
set_include_path(implode(PATH_SEPARATOR, array( 
    LIBRARY_PATH, get_include_path(), 
))); 
set_time_limit(0);
ini_set('memory_limit', '-1');
ini_set("soap.wsdl_cache_enabled", "0");

require_once 'Zend/Application.php' ;
$application = new Zend_Application( 
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini' 
); 
$application->bootstrap()->run();


function pr($data, $die = true)
{
    $allowIp = array('127.0.0.1');
    if (in_array($_SERVER["REMOTE_ADDR"],$allowIp)) {
        $numargs = func_num_args();
        $data = func_get_args();
        if($numargs == 1){
            $data = $data[0];
        }

        $trace = debug_backtrace();
        $caller = array_shift($trace);
        echo '<pre>';
        echo "called by [" . $caller['file'] . "] line: " . $caller['line'] . "\n";
        print_r($data);
        if ($die) {
            die();
        }
    }
}